﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QuanLyTiemVang.DTO;

namespace QuanLyTiemVang.DAO
{
    class ChiTietPhieuHangGiaCongDAO
    {
        private static QUANLYTIEMVANGEntities dbContext = new QUANLYTIEMVANGEntities();

        static public List<CHITIETPHIEUHANGGIACONG> GetAllChiTietPhieuHangGiaCong()
        {
            var query = from d in dbContext.CHITIETPHIEUHANGGIACONGs
                        select d;

            if (query.ToList().Count == 0)
                return null;

            return query.ToList();
        }
        public static void Insert(CHITIETPHIEUHANGGIACONG ctphgc)
        {
            dbContext.CHITIETPHIEUHANGGIACONGs.Add(ctphgc);
            dbContext.SaveChanges();
        }
        public static void Delete(CHITIETPHIEUHANGGIACONG ctphgc)
        {
            if (dbContext.CHITIETPHIEUHANGGIACONGs.Find(ctphgc.MaChiTietPhieuHangGiaCong) == null)
                return;

            dbContext.CHITIETPHIEUHANGGIACONGs.Remove(ctphgc);
            dbContext.SaveChanges();
        }
    }
}
